﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Prism.Mvvm;

namespace MachineVision.Core.TemplateMatch.Shared
{
    /// <summary>
    /// 匹配结果
    /// </summary>
    public class MatchResult : BindableBase
    {
        private string message;

        public MatchResult(double timeSpan, ObservableCollection<TemplateMatchResult>? result)
        {
            TimeSpan = timeSpan;
            Results = result;
            //Message = $"匹配耗时:{TimeSpan}ms," + $"{(Results.Count > 0 ? $"匹配个数:{Results.Count}" : "未匹配相关数据")}";
        }

        public MatchResult()
        {
            Results = new ObservableCollection<TemplateMatchResult>();
            //Message = $"匹配耗时:{TimeSpan}ms," + $"{(Results.Count > 0 ? $"匹配个数:{Results.Count}" : "未匹配相关数据")}";
        }

        public string Message
        {
            get => message;
            set
            {
                message = value;
                RaisePropertyChanged();
            }
        }

        public double TimeSpan { get; set; }
        public bool IsSuccess => Results?.Count > 0;
        public ObservableCollection<TemplateMatchResult> Results { get; set; }
    }

    public class MatchResultSetting : BindableBase
    {
        private bool isShowCenter;
        private bool isShowDisplayText;
        private bool isShowMatchRange;

        public MatchResultSetting()
        {
            IsShowCenter = true;
            IsShowMatchRange = true;
            IsShowDisplayText = true;
        }

        /// <summary>
        ///显示匹配中心
        /// </summary>
        public bool IsShowCenter
        {
            get => isShowCenter;
            set
            {
                isShowCenter = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 显示文本
        /// </summary>
        public bool IsShowDisplayText
        {
            get => isShowDisplayText;
            set
            {
                isShowDisplayText = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 显示检测范围
        /// </summary>
        public bool IsShowMatchRange
        {
            get => isShowMatchRange;
            set
            {
                isShowMatchRange = value;
                RaisePropertyChanged();
            }
        }
    }
}
